import axios from 'axios'
import Cookies from 'js-cookie'
axios.defaults.withCredentials = false;
axios.defaults.timeout = 180000;
axios.interceptors.request.use(
    config => {
      let signature=Cookies.get('token');
      if(signature){
        config.headers.Signature = signature;
      }
      return config
    },
    error => {
        return Promise.reject(error)
    }
);
export const POST = (url, params) => {
    return axios.post(`${url}`, params).then(res => res.data)
};
export const PostFormData = (url, params) => {
    return axios.post(url,qs.stringify(params), {headers: {'Content-Type':'application/x-www-form-urlencoded'}}).then(res => res.data);
};

export const GET = (url, params) => {
  return axios.get(`${url}`, {
    params: params
  }).then(res => res.data)
};
export const POSTBLOB = (url, params) => {
  return axios({
    method:'post',
    url:`${url}`,
    data:params,
    responseType:'blob'
  }).then(res => res.data)
};
export const GETBLOB = (url, params) => {
  return axios.get(`${url}`, {
    params: params,
    responseType:'blob'
  }).then(res => res.data)
};
export const GETBLOBAll = (url, params) => {
  return axios.get(`${url}`, {
    params: params,
    responseType:'blob'
  }).then(res => res)
};
export const POSTBLOBAll = (url, params) => {
  return axios({
    method:'post',
    url:`${url}`,
    data:params,
    responseType:'blob'
  }).then(res => res)
};
export const GET2 = (url, params) => {
  return axios.get(`${url}`, {
    params: params
  }).then(res => res.data)
};

export const PUT = (url, params) => {
    return axios.put(`${url}`, params).then(res => res.data)
};
